<div class="fly-panel fly-column">
  <div class="layui-container">
    <ul class="layui-clear">
      <li class="{$cateid == '' ? 'layui-hide-xs layui-this' : ''}"><a href="{:url('home/index/index')}">全部</a></li>
      {foreach($cateList as $item)}
      <li class="{$cateid == $item.id ? 'layui-hide-xs layui-this' : ''}"><a
          href="{:url('home/index/index',['cateid' => $item.id])}">{$item.name}</a></li>
      {/foreach}
      <li class="layui-hide-xs layui-hide-sm layui-show-md-inline-block"><span class="fly-mid"></span></li>

      <!-- 用户登入后显示 -->
      {if condition="$Think.cookie.LoginUser"}
      <li class="layui-hide-xs layui-hide-sm layui-show-md-inline-block"><a href="{:url('home/post/index')}">我发表的贴</a></li>
      <li class="layui-hide-xs layui-hide-sm layui-show-md-inline-block"><a href="{:url('home/post/collect')}">我收藏的贴</a>
      </li>
      {/if}
    </ul>

    <div class="fly-column-right layui-hide-xs">
      <span class="fly-search"><i class="layui-icon"></i></span>
      <a href="{:url('home/post/add')}" class="layui-btn">发表新帖</a>
    </div>
    <div class="layui-hide-sm layui-show-xs-block" style="margin-top: -10px; padding-bottom: 10px; text-align: center;">
      <a href="{:url('home/post/add')}" class="layui-btn">发表新帖</a>
    </div>
  </div>
</div>

<div class="layui-container">
  <div class="layui-row layui-col-space15">
    <div class="layui-col-md8">
      <!-- 置顶模块页面、 -->

      <div class="fly-panel">
        <div class="fly-panel-title fly-filter">
          <a>置顶</a>
          <!-- <a href="#signin" class="layui-hide-sm layui-show-xs-block fly-right" id="LAY_goSignin"
            style="color: #FF5722;">去签到</a> -->
        </div>
        <!-- 置顶模块页面、 -->
        <ul class="fly-list">
          {if condition="$topList"}
          {foreach($topList as $item)}
          <li>
            <!-- 头像链接 -->
            <a href="{:url('home/user/index',['userid'=> $item.user.id])}" class="fly-avatar">
              <img src="{$item.user.avatar ? $item.user.avatar : '/static/home/res/images/avatar/default.png'}"
                alt="贤心">
            </a>
            <!-- 标题 -->
            <h2>
              <a class="layui-badge">{$item.cate.name}</a>
              <a href="{:url('home/index/info',['postid' => $item.id])}">{$item.title}</a>
            </h2>
            <div class="fly-list-info">
              <!-- 昵称 -->
              <a href="{:url('home/user/index',['userid' => $item.user.id])}" link>
                <cite>{$item.user.nickname}</cite>
                <i class="iconfont icon-renzheng" title="认证信息：{$item.user.nickname}"></i>
                <i class="layui-badge fly-badge-vip">{$item.user.vip}</i>
              </a>
              <!-- 发布时间 -->
              <span>{$item.createtime}</span>
              <!-- 积分数 -->
              <span class="fly-list-kiss layui-hide-xs" title="悬赏飞吻"><i class="iconfont icon-kiss"></i>
                {$item.point}</span>
              {if condition="$item.accept"}
              <span class="layui-badge fly-badge-accept layui-hide-xs">已结</span>
              {/if}
              <!-- 评论数 -->
              <span class="fly-list-nums">
                <i class="iconfont icon-pinglun1" title="回答"></i> {$item.comment}
              </span>
            </div>
            <div class="fly-list-badge">
                <span class="layui-badge layui-bg-black">置顶</span>
            </div>
          </li>
          {/foreach}
          {else /}
          <div class="fly-none" style="min-height: 70px;">暂无数据</div>
          {/if}
        </ul>
      </div>
     
      <div class="fly-panel" style="margin-bottom: 0;">
         <!-- 筛选内容模块页面、 -->
        <div class="fly-panel-title fly-filter">
          <a href="{:url('home/index/index')}" class="{$accept === '' ? 'layui-this':''}">全部</a>
          <span class="fly-mid"></span>
          <a href="{:url('home/index/index',['cateid' => $cateid,'accept'=> 0])}"
            class="{$accept === '0' ? 'layui-this' : ''}">未结</a>
          <span class="fly-mid"></span>
          <a href="{:url('home/index/index',['cateid' => $cateid,'accept'=> 1])}"
            class="{$accept === '1' ? 'layui-this' : ''}">已结</a>
        </div>
        <!-- 帖子列表 -->
        <ul class="fly-list">
          {foreach($PostList as $item)}
          <li>
            <!-- 头像链接 -->
            <a href="{:url('home/user/index',['userid'=> $item.user.id])}" class="fly-avatar">
              <img src="{$item.user.avatar ? $item.user.avatar : '/static/home/res/images/avatar/default.png'}" alt="">
            </a>
            <!-- 标题 -->
            <h2>
              <a class="layui-badge">{$item.cate.name}</a>
              <a href="{:url('home/index/info',['postid' => $item.id])}">{$item.title}</a>
            </h2>
            <div class="fly-list-info">
              <!-- 昵称 -->
              <a href="{:url('home/user/index',['userid'=> $item.user.id])}" link>
                <cite>{$item.user.nickname}</cite>
                <i class="iconfont icon-renzheng" title="认证信息：{$item.user.nickname}"></i>
                <i class="layui-badge fly-badge-vip">{$item.user.vip}</i>
              </a>
              <!-- 发布时间 -->
              <span>{$item.time}</span>
              <!-- 积分数 -->
              <span class="fly-list-kiss layui-hide-xs" title="悬赏飞吻"><i class="iconfont icon-kiss"></i>
                {$item.point}</span>
              <!-- 评论数 -->
              <span class="fly-list-nums">
                <i class="iconfont icon-pinglun1" title="回答"></i> {$item.comment}
              </span>
            </div>
            <!-- 帖子状态 -->
            <div class="fly-list-badge">
              {if condition="$item.state eq 1"}
              <span class="layui-badge layui-bg-red">置顶</span>
              {elseif condition="$item.state eq 2"}
              <span class="layui-badge layui-bg-red">精华</span>

              {elseif condition="$item.state eq 3"}
              <span class="layui-badge layui-bg-red">热门</span>
              {/if}
            </div>
          </li>
          {/foreach}
        </ul>
        <!-- 分页 -->
        {$PostList->render()}
      </div>
    </div>
    <div class="layui-col-md4">
      <!-- 签到 -->
      <div class="fly-panel fly-signin">
        <div class="fly-panel-title">
          签到
          <i class="fly-mid"></i>
          <a href="javascript:;" class="fly-link" id="LAY_signinHelp">说明</a>
          <i class="fly-mid"></i>
          <a href="javascript:;" class="fly-link" id="LAY_signinTop">活跃榜<span class="layui-badge-dot"></span></a>
          <span class="fly-signin-days">已连续签到<cite>{$daylinsum}</cite>天</span>
        </div>
        <div class="fly-panel-main fly-signin-main">
          {if condition="$daytype"}
          <!-- 已签到状态 -->
          <button class="layui-btn layui-btn-disabled signin">今日已签到</button>
          {else /}
          <button class="layui-btn layui-btn-danger signin" id="LAY_signin">今日签到</button>
          {/if}
          <span>可获得<cite>5</cite>积分</span>
        </div>
      </div>
      <!-- 本周热议 -->
      <div class="fly-panel">
        <h3 class="fly-panel-title">本周热议</h3>
        <ol class="fly-panel-main fly-list-static" type="1">
          {foreach $comhot as $item}
          {if $item.commentpost}
          <li>
            <a href="{:url('home/index/info', ['postid' => $item['postid']])}" target="_blank">{$item.commentpost}</a>
          </li>
          {/if}
          {/foreach}
        </ol>
      </div>
      <!-- 回贴周榜 -->
      <div class="fly-panel fly-rank fly-rank-reply" id="LAY_replyRank">
        <h3 class="fly-panel-title">回贴周榜</h3>
        <dl>
          <!--<i class="layui-icon fly-loading">&#xe63d;</i>-->
          {foreach $reply as $item}
          <dd>
            <a href="{:url('home/user/index', ['userid' => $item['userid']])}">
              <img
                src="https://tva1.sinaimg.cn/crop.0.0.118.118.180/5db11ff4gw1e77d3nqrv8j203b03cweg.jpg"><cite>{$item.commenthot}</cite><i>{$item.p}次回答</i>
            </a>
          </dd>
          {/foreach}
        </dl>
      </div>
      <!-- 微信公众号 -->
      <div class="fly-panel" style="padding: 20px 0; text-align: center;">
        <img src="/static/home/res/images/weixin.jpg" style="max-width: 100%;" alt="layui">
        <p style="position: relative; color: #666;">微信扫码关注 layui 公众号</p>
      </div>
    </div>
  </div>
</div>

<script>

  layui.use(['layer'], function () {
      var $ = layui.jquery,
        layer = layui.layer;
      //签到
      $('.signin').on('click', function () {

        //发送异步请求
        $.ajax({
          url: `{:url('home/index/sigin')}`,
          type: 'post',
          data: `userid={$Think.cookie.LoginUser['id']}`,
          dataType: 'json',
          success: function (success) {
            if (success.result) {
              //成功
              layer.msg(success.msg, {
                icon: 1,
                time: 1000 //2秒关闭（如果不配置，默认是3秒）
              }, function () {
                //直接刷新界面
                location.reload()
              })
              console.log("签到成功");
            } else {
              //失败
              layer.msg(success.msg);
              $(this).attr("disabled", "disabled");
              console.log("签到失败");
            }
          }
        })
      })
    })

</script>